# # 
#  Command.py
#  ExpectIT
#  
#  Author: Marvin S. Addison
#  Date: 2007-10-15
#  Version: $Revision: $
#  Updated: $Date: $
#  Copyright 2008 Marvin S. Addison. All rights reserved.
#  See LICENSE.txt for licensing information.
#

import util

class Command:
	"""A command that may be executed within a session on a remote host."""
	def __init__(self):
		self.command = ''
		self.show_output = True
		self.expect = None
		self.timeout = None

	def clone(self):
		"""Performs a shallow clone operation on this Command object using
		the optional given string for the command instead of the former value."""
		new_cmd = Command()
		util.clone(self, new_cmd)
		return new_cmd

	def __str__(self):
		return self.command

def from_dict(dict):
	"""Creates a new Command object initialized with properties from the
	supplied dictionary."""
	command = Command()
	util.load_object(command, dict)
	return command
